package lz;

import java.util.concurrent.atomic.AtomicInteger;


public class TreeMain {
    public void buildAndPrint() {
        LZTree<Integer> treeGen = new LZTree<>();

        //整数树
        AtomicInteger atomic = new AtomicInteger(1);
        LZTree.Node<Integer> root1 = treeGen.buildFullBinaryTreeWithValue(4,()->{
            return atomic.getAndIncrement();
        });

        AtomicInteger atomic2 = new AtomicInteger(16);
        LZTree.Node<Integer> root2 = treeGen.buildFullBinaryTreeWithValue(4,()->{
            return atomic2.getAndIncrement();
        });

        AtomicInteger atomic3 = new AtomicInteger(31);
        LZTree.Node<Integer> root3 = treeGen.buildFullBinaryTreeWithValue(4,()->{
            return atomic3.getAndIncrement();
        });

        AtomicInteger atomic4 = new AtomicInteger(46);
        LZTree.Node<Integer> root4 = treeGen.buildFullBinaryTreeWithValue(4,()->{
            return atomic4.getAndIncrement();
        });


        root1.setParent(root2);
        root2.setParent(root3);
        root3.setParent(root4);
        root4.setParent(root1);
//        treeGen.traversalLinkTree(root1);
//        treeGen.queueTraversal(root1);

//        1, 2, 4, 8, 9, 5, 10, 11, 3, 6, 12, 13, 7, 14, 15
//        treeGen.preDepthTraversal(root1);

//        8, 4, 9, 2, 10, 5, 11, 1, 12, 6, 13, 3, 14, 7, 15
//        treeGen.middleDepthTraversal(root1);

//        8, 9, 4, 10, 11, 5, 2, 12, 13, 6, 14, 15, 7, 3, 1

    }

    public static void main(String[] args) {
        new TreeMain().buildAndPrint();
    }
}
